﻿@model NewTypeView
<div class="layui-container" style="margin-top:50px;margin-bottom:150px">
    @*不要from提交*@
    <form class="layui-form" id="addFrom" onsubmit="return false">
        <input type="hidden" asp-for="Id" />
        <div class="layui-form-item">
            <!--用户名-->
            <label class="layui-form-label">名字</label>
            <div class="layui-input-inline">
                <input type="text" asp-for="Name" required lay-verify="title" autocomplete="off" class="layui-input">
                <span asp-validation-for="Name" style="color: #F56C6C"></span>
                @*<input type="text" id="Name" value="@ViewBag.A.Name" class="layui-input" />*@
            </div>
        </div>
        @*提交和重置按钮*@
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="subAdd">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>


    </form>
</div>
@section Scripts{
    <script>
        layui.use(['form', 'layer', 'layedit'], function () {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit;

            //监听提交
            form.on('submit(subAdd)', function (data) {
                console.log(data.field);
                $.post("/Admin/NewsType/Edit", data.field, function (re) {
                    if (re.success) {
                        //发异步，把数据提交给
                        layer.alert(re.msg, { icon: 6 }, function () {
                            parent.layui.$("#btnSearch").click();
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            //3,刷新父级页面
                            parent.location.reload();
                        });
                    } else {
                        layer.msg(re.msg);
                    }

                }, "json");

                return false;
            });


        });
    </script>
}
